public class Solution242 {
    public boolean isAnagram(String s, String t) {
        int[] f=new int[26];
        int[] g=new int[26];
        for (char c : s.toCharArray()) {
            f[c-'a']++;
        }
        for (char c : t.toCharArray()) {
            g[c-'a']++;
        }
        for (int i=0;i<26;i++){
            if (f[i]!=g[i]){
                return false;
            }
        }
        return true;
    }

    public static void main(String[] args) {
        System.out.println(new Solution242().isAnagram("anagram","nagaram"));
    }
}
